﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BOHVote.BLL;

namespace BOH.AccreditationSystem
{
    public partial class ReportInterviewResults : System.Web.UI.Page
    {
        public string Passed = string.Empty;
        public string UnPassed = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SubjectBindID();
                //BindApplyStyle();
            }
            
        }

        #region <<  Drop down list  >>
        public void SubjectBindID()
        {
            this.drpSubject.Items.Clear();
            ListItem li1 = new ListItem("请选择学科组", "-1");
            this.drpSubject.Items.Add(li1);
            DataSet dst = Subject.getAllASubject();

            foreach (DataRow dr in dst.Tables[0].Rows)
            {
                if (dr["SubjectID"].ToString().Length > 0)
                {
                    ListItem li = new ListItem(dr["SubjectName"].ToString(), dr["SubjectID"].ToString());
                    this.drpSubject.Items.Add(li);
                }
            }
        }
        #endregion

        public void SetPassNu()
        {
            DataSet dst = InterviewClass.getResults("", "-1", drpSubject.SelectedValue.Trim(), "-1", "-1", "-1", (string)Session["ApplyPeriod"], "G");//(string)Session["ApplyPeriod"]);
            double TotalApply = dst.Tables[0].Rows.Count;
            double ApplyPassed = dst.Tables[0].Select("PassInd='Y'").Length;
            double ApplyUnPassed = dst.Tables[0].Select("PassInd='N'").Length;
            if (TotalApply != 0)
            {
                Passed = ((ApplyPassed / TotalApply)*100).ToString("#.##");
                if (String.IsNullOrEmpty(Passed))
                    Passed = "0";
                UnPassed =((ApplyUnPassed / TotalApply)*100).ToString("#.##");
                if (String.IsNullOrEmpty(UnPassed))
                    UnPassed = "0";
            }
        }

        protected void butShow_Click(object sender, EventArgs e)
        {
            SetPassNu();
            container.Style["display"] = "block";
        }
    }
}
